package com.chen.dataupload.data;

import com.chen.dataupload.entity.Student;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class CreateData {

    public static String createJsonData() throws JsonProcessingException {
        List<Student> list = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {
            Student student = new Student();
            student.setId(i);
            student.setAge(i);
            student.setCreatedDate(new Date());
            student.setName("第"+i+"人物");
            list.add(student);
        }

        ObjectMapper mapper = new ObjectMapper();
        String data = mapper.writeValueAsString(list);
        return data;
    }

    public static void main(String[] args) throws Exception {
        System.out.println(createJsonData());
    }
}
